package com.prs.crm.dao.cdxh.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.cdxh.DistributionReturnDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.cdxh.DistributionOrderDetail;
import com.prs.crm.domain.cdxh.distribution.DistributionReturn;
import com.prs.crm.domain.cdxh.distribution.DistributionReturnDetail;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-1-10 上午10:30:34
 * 简单说明
 */

public class DistributionReturnDaoImpl extends BaseDaoImpl<DistributionReturn>
		implements DistributionReturnDao {

	@Override
	public void saveOrUpdis(DistributionReturn distributionReturn) {
		this.getHibernateTemplate().saveOrUpdate(distributionReturn);
		
	}

	@Override
	public void saveOrUpdisdetail(
			DistributionReturnDetail distributionReturnDetail) {
	this.getHibernateTemplate().saveOrUpdate(distributionReturnDetail);
		
	}

	@Override
	public List<DistributionReturn> getDistributionReturn(final String codePlanOrder) {
		 return (List<DistributionReturn>) this.getHibernateTemplate().execute(
					new HibernateCallback()
					{
						public Object doInHibernate(Session session) throws HibernateException {
				        	Criteria criteria = session.createCriteria(DistributionReturn.class);
				        	criteria.add(Restrictions.eq("reOrderCode", codePlanOrder));
				     
				        	
							return criteria.list();
				        	
				        	
				        }
					}
			);
	}

}
